Component({
  properties: {
    like: Boolean,
    count: Number
  },
  data: {
    onLike: `iconfont iconlikefill`,
    offLike: `iconfont iconlike`
  },
  methods: {
    onLike (e) {
      let like = this.properties.like,
          count = this.properties.count,
          behavior = !this.properties.like ? 'like' : 'cancel'
      count = like ? count - 1 : count + 1
      this.setData({
        count: count,
        like: !like
      })
      this.triggerEvent('like', {
        behavior
      }, {})
    }
  },
  externalClasses: ['iconfont', 'iconlike', 'iconlikefill']
})
